#include <iostream>
using namespace std;
const int N = 2010;
int n, m;
string s, t;
int dp[N][N];

int main()
{
    cin >> s >> t;
    n = s.size();
    m = t.size();
    for (int i = 1; i <= n; i++)
        dp[i][0] = i;
    for (int j = 1; j <= m; j++)
        dp[0][j] = j;

    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
        {
            if (s[i - 1] == t[j - 1])
                dp[i][j] = dp[i - 1][j - 1];
            else
            {
                dp[i][j] = min(min(dp[i - 1][j], dp[i - 1][j - 1]), dp[i][j - 1]) + 1;
            }
        }
        cout << dp[n][m] << endl;
    return 0;
}